package com.jty.lib_base.data

import com.jty.lib_base.base.BaseBean
import com.jty.lib_base.base.BaseModel
import com.jty.lib_base.data.bean.*
import com.jty.lib_base.data.source.HttpDataSource
import com.jty.lib_base.data.source.LocalDataSource
import io.reactivex.Observable
import okhttp3.RequestBody
import java.io.Serializable


/**
 * author: zhouyh
 * created on: 2021/5/11 4:59 下午
 * description:数据中心（本地+在线） 外部通过Koin依赖注入调用
 * 对于缓存或者在线数据的增删查改统一通过该数据仓库调用
 */
class DataRepository constructor(
    private val mHttpDataSource: HttpDataSource,
    private val mLocalDataSource: LocalDataSource,
) : BaseModel(), LocalDataSource, HttpDataSource {


    override fun login(requestBody: RequestBody): Observable<BaseBean<LoginBean>> {
        return mHttpDataSource.login(requestBody)
    }


    override fun getToken(
        grant_type: String,
        client_id: String,
        client_secret: String,
        device_type: String,
        account: String,
        password: String,
    ): Observable<BaseBean<TokenBean>> {
        return mHttpDataSource.getToken(grant_type,client_id,client_secret,device_type,account,password)
    }

    override fun getCode(requestBody: RequestBody): Observable<BaseBean<String>> {
        return mHttpDataSource.getCode(requestBody)
    }


    override fun rePassword(requestBody: RequestBody): Observable<BaseBean<Any?>> {
        return mHttpDataSource.rePassword( requestBody)
    }

    override fun getUserInfo(): Observable<BaseBean<UserInfoBean>> {
        return mHttpDataSource.getUserInfo()
    }


    override fun querySection(): Observable<BaseBean<List<SectionBean>>> {
        return mHttpDataSource.querySection()
    }

    override fun querySubject(): Observable<BaseBean<List<SubjectBean>>> {
        return mHttpDataSource.querySubject()
    }


    override fun modifyUserInfo(requestBody: RequestBody): Observable<BaseBean<Any?>> {
        return mHttpDataSource.modifyUserInfo(requestBody)
    }

    override fun modifyPhone(requestBody: RequestBody): Observable<BaseBean<Any?>> {
        return mHttpDataSource.modifyPhone(requestBody)
    }

    override fun getSchoolPhaseSubjectList(requestBody: RequestBody): Observable<BaseBean<List<UserInfoBean>>> {
        return mHttpDataSource.getSchoolPhaseSubjectList(requestBody)
    }

    override fun modifyPassword(requestBody: RequestBody): Observable<BaseBean<Any?>> {
        return mHttpDataSource.modifyPassword(requestBody)
    }

    override fun getTeacherPen(): Observable<BaseBean<TeacherPenBean>> {
        return mHttpDataSource.getTeacherPen()
    }



    override fun pageBybookNote(requestBody: RequestBody): Observable<BaseBean<PageBybookNoteBean>> {
        return mHttpDataSource.pageBybookNote(requestBody)
    }

    override fun bookNoteByTeacherId(requestBody: RequestBody): Observable<BaseBean<List<GridPictureBean>>> {
        return mHttpDataSource.bookNoteByTeacherId(requestBody)
    }

    override fun getNoteTemplateInfo1(requestBody: RequestBody): Observable<BaseBean<BookNoteBean>> {
        return mHttpDataSource.getNoteTemplateInfo1(requestBody)
    }

    override fun commitTeacherBookNote(requestBody: RequestBody): Observable<BaseBean<Any?>> {
        return mHttpDataSource.commitTeacherBookNote(requestBody)
    }

    override fun commitTeacherBookNoteOnLine(requestBody: RequestBody): Observable<BaseBean<Any?>> {
        return mHttpDataSource.commitTeacherBookNoteOnLine(requestBody)
    }

    override fun createTeacherWriteRecord(requestBody: RequestBody): Observable<BaseBean<Any?>> {
        return mHttpDataSource.createTeacherWriteRecord(requestBody)
    }

    override fun queryLastVersion(version: String): Observable<BaseBean<VersionInfoBean>> {
        return mHttpDataSource.queryLastVersion(version)
    }




    override fun checkTeacherMac(requestBody: RequestBody): Observable<BaseBean<CheckTeacherMacBean>> {
        return mHttpDataSource.checkTeacherMac(requestBody)
    }
    override fun teacherConfirmConnect(requestBody: RequestBody): Observable<BaseBean<Any?>> {
        return mHttpDataSource.teacherConfirmConnect(requestBody)
    }

    override fun getOneNoteTemplateInfo(requestBody: RequestBody): Observable<BaseBean<GridPictureBean>> {
        return mHttpDataSource.getOneNoteTemplateInfo(requestBody)
    }



    override fun getResearchTabData(requestBody: RequestBody): Observable<BaseBean<List<ResearchTabBean>>> {
        return mHttpDataSource.getResearchTabData(requestBody)
    }

    override fun queryResearchActivity(requestBody: RequestBody): Observable<BaseBean<ResearchActivityListBean>> {
        return mHttpDataSource.queryResearchActivity(requestBody)
    }

    override fun getResearchActivityDetail(requestBody: RequestBody): Observable<BaseBean<ResearchDetailBean>> {
        return mHttpDataSource.getResearchActivityDetail(requestBody)
    }

    override fun getResearchJoinPeople(requestBody: RequestBody): Observable<BaseBean<List<ResearchJoinPeopleBean>>> {
        return mHttpDataSource.getResearchJoinPeople(requestBody)
    }

    override fun joinResearchActivity(requestBody: RequestBody): Observable<BaseBean<Any>> {
       return mHttpDataSource.joinResearchActivity(requestBody)
    }

    override fun uploadResearchNote(requestBody: RequestBody): Observable<BaseBean<Any>> {
        return mHttpDataSource.uploadResearchNote(requestBody)
    }

    override fun getRoomUuidAndToken(requestBody: RequestBody): Observable<BaseBean<WhiteboardTokenBean>> {
        return mHttpDataSource.getRoomUuidAndToken(requestBody)
    }

    override fun getWhiteboardToken(uuid: String,requestBody: RequestBody): Observable<String> {
        return mHttpDataSource.getWhiteboardToken(uuid,requestBody)
    }


    override fun getRoomToken(requestBody: RequestBody): Observable<BaseBean<RoomTokenBean>> {
        return mHttpDataSource.getRoomToken(requestBody)
    }

    override fun deleteResearchNote(requestBody: RequestBody): Observable<BaseBean<Any>> {
        return mHttpDataSource.deleteResearchNote(requestBody)
    }

    override fun sharePics(requestBody: RequestBody): Observable<BaseBean<String>> {
        return mHttpDataSource.sharePics(requestBody)
    }

    override fun getRoomNote(requestBody: RequestBody): Observable<BaseBean<RoomNoteBean>> {
        return mHttpDataSource.getRoomNote(requestBody)
    }

    override fun getLiveState(requestBody: RequestBody): Observable<BaseBean<LiveStateBean>> {
        return mHttpDataSource.getLiveState(requestBody)
    }


    override fun saveLoginData(loginBean: LoginBean) {
        mLocalDataSource.saveLoginData(loginBean)
    }

    override fun getLoginData(): LoginBean? {
        return mLocalDataSource.getLoginData()
    }


    override fun getUserInfoData(): UserInfoBean? {
        return mLocalDataSource.getUserInfoData()
    }

    override fun getPenMac(): String? {
        return mLocalDataSource.getPenMac()
    }

    override fun <T : Serializable> saveCacheListData(list: List<T>) {
        return mLocalDataSource.saveCacheListData(list)
    }

    override fun <T : Serializable> getCacheListData(key: String): List<T>? {
        return mLocalDataSource.getCacheListData(key)
    }

    override fun saveCurrentStudyYearData(studyYearBean: CurrentStudyYearBean) {
        mLocalDataSource.saveCurrentStudyYearData(studyYearBean)
    }

    override fun getCurrentStudyYearData(): CurrentStudyYearBean? {
        return mLocalDataSource.getCurrentStudyYearData()
    }

    override fun savePwdFlag(isVisible: Boolean) {
        return mLocalDataSource.savePwdFlag(isVisible)
    }

    override fun getPwdFlag(): Boolean {
        return mLocalDataSource.getPwdFlag()
    }


    override fun getLoginName(): String?{
        return mLocalDataSource.getLoginName()
    }

    override fun getLoginPassword(): String? {
        return mLocalDataSource.getLoginPassword()
    }

    override fun saveAccountAndPwd(account: String, password: String) {
        return mLocalDataSource.saveAccountAndPwd(account,password)
    }

    override fun savePenMac(penMac: String) {
        return mLocalDataSource.savePenMac(penMac)
    }

    override fun getUserId():Int? {
        return mLocalDataSource.getUserId()
    }

    override fun getUserName():String? {
        return mLocalDataSource.getUserName()
    }

    override fun isLogin(): Boolean {
        return mLocalDataSource.isLogin()
    }

    override fun saveLoginState(isLogin: Boolean) {
        return mLocalDataSource.saveLoginState(isLogin)
    }


    override fun getToken(): String? {
        return mLocalDataSource.getToken()
    }


    override fun saveUserInfoData(userBean: UserInfoBean) {
        mLocalDataSource.saveUserInfoData(userBean)
    }

    override fun outLoginReset() {
        mLocalDataSource.outLoginReset()
    }


}